﻿/*
 C型钩
 
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

using System.Data;
using CSharpConnectMySQL;

namespace Dingding.Helper
{
    public class MatHangerNumber
    {

        /// <summary>
        /// C型购号
        /// </summary>
        /// <param name="HangerNumber"></param>
        /// <returns></returns>
        public static string GetHangerNumber_OK(string HangerNumber,int ip)
        {
            string strResult = HangerNumber;

            int number;
            int.TryParse(HangerNumber, out number);



            //修正； 

            //不同摄像头的光线也不一样的；
            //if (ip==16) 


            //1位修正
            if (strResult.Length == 1 )
            {
                //38号线架问题已经解决；

                //if (strResult == "3")//13号，7号摄像头
                //{
                //    strResult = "38";
                //} 

                //upload / ai_camera / 2024 - 07 - 08 / IP_10.233.121.16 / IMG_1720437628198.jpg 【76识别成7了】


                //物料跟踪号【2408020204】97识别成7了
                //if (strResult == "7")// 
                //{
                //    strResult = "76";
                //}


                //临时补丁；2024-11-02； 11钩识别不出来
               if  (ip == 16 && strResult == "1")
                {
                    strResult = "11";
                }



            }
            //3位修正

            //else if (strResult == "620") //upload / ai_camera / 2024 - 07 - 22 / IP_10.233.121.7 / IMG_1721600191042.jpg
            //{
            //    strResult = "20";
            //}
            //else if (strResult == "130") //upload / ai_camera / 2024 - 07 - 22 / IP_10.233.121.7 / IMG_1721603407661.jpg
            //{
            //    strResult = "30";
            //}
            //else if (strResult == "105") //upload/ai_camera/2024-07-22/IP_10.233.121.7/IMG_1721603556038.jpg
            //{
            //    strResult = "05";
            //}

            else if (strResult.Length == 3 
                &&  number >121
                && (ip == 16  || ip == 17 ) //ad by wb 2024--8-08 只有称重才可以直接取前2位，待后面完善后都应获取识别率最高的，方差最接近的
                )
            { 
                  //拍摄到其他线架了；如：upload/ai_camera/2024-05-31/IP_10.233.121.16/IMG_1717089537963.jpg 
                 //strResult = strResult.Substring(0, 2);
            } 

            
            return strResult;
        }

        public static string GetHangerNumber(string ip )
        {
            string strResult = "-1"; 

            //获取需要修改的记录；
            string sql = " select SHELF_NUMBER from tmm0001_ocr_wb "
                            + "  where ip = " + ip + "  "
                            + " and REC_CREATE_TIME > UNIX_TIMESTAMP(DATE_SUB(NOW(3), INTERVAL 30 SECOND)) * 1000 "
                            + " order by REC_CREATE_TIME desc "
                            ; 
            DataSet dataSet = MySqlHelper2.GetDataSet(sql); 
            if (dataSet.Tables[0].Rows.Count>0)
            {
                strResult = dataSet.Tables[0].Rows[0][0].ToString();
            }

            return strResult;
        }



    }
}